package com.coollang.smartbra.adapter;

import com.chad.library.adapter.base.BaseMultiItemQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.coollang.smartbra.R;
import com.coollang.smartbra.beans.NewActionData;
import com.coollang.smartbra.utils.ActionTypeParse;

import java.util.List;

/**
 * @author: Timmy
 * @data: 2017/12/15
 * @Fuction:
 */

public class NewCountActionDetailsAdapter extends BaseMultiItemQuickAdapter<NewActionData, BaseViewHolder> {

    public NewCountActionDetailsAdapter(List<NewActionData> data) {
        super(data);
        addItemType(NewActionData.ACTION_CORRECT_FLAG, R.layout.item_countaction_correct);
        addItemType(NewActionData.ACTION_ERROR_FLAG, R.layout.item_countaction_error);
    }

    @Override
    protected void convert(BaseViewHolder holder, NewActionData item) {

        int itemCount = getItemCount();
        int position = holder.getAdapterPosition();
        int currentPosition = itemCount - position;
        holder.setText(R.id.tv_postion, String.valueOf(currentPosition));

        switch (holder.getItemViewType()) {
            case NewActionData.ACTION_CORRECT_FLAG:
                break;
            case NewActionData.ACTION_ERROR_FLAG:
                String errorInfo = ActionTypeParse.parseErrorType(item.getActionType(), item.getErrorType());
                holder.setText(R.id.tv_errorinfo, errorInfo);
                break;
            default:
                break;
        }
    }

}


